import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import DefaultLayout from '../layout/DefaultLayout.vue'
import RouterViewLayout from '../layout/RouterViewLayout.vue'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: '/dashboard',
  },
  {
    path: '/',
    name: 'index',
    meta: { title: 'Home' },
    component: DefaultLayout,
    redirect: '/dashboard/home',
    children: [
      {
        path: '/dashboard',
        name: 'dashboard',
        redirect: '/dashboard/home',
        component: RouterViewLayout,
        meta: { title: '首页', icon: 'home-outlined' },
        children: [
          {
            path: '/dashboard/home',
            name: '首页',
            component: () => import('../pages/dashboard/Home.vue'),
            meta: {
              title: '首页',
              keepAlive: false,
            },
          },
        ],
      },
      {
        path: '/test',
        name: 'test',
        meta: { title: '测试', icon: 'icon-antdesign' },
        component: () => import('../pages/Test.vue'),
      },
      {
        path: '/test2',
        name: 'test2',
        meta: { title: 'test2', icon: 'icon-antdesign' },
        component: () => import('../pages/Test2.vue'),
      },
    ],
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

export default router
